package pshycomanagement

class SecurityController {

  def index = {
        redirect action:"login", params:params
    }
 def login = {}
 def userMenu = {}
 def adminMenu = {}
    def verify = {
        def user1 = Security.findByUserNameAndPassword(params.userName,params.password,params.securityLevel)
            if(user1){
                if (user1.securityLevel == "User"){
                    redirect(action:"userMenu")
                    session.user= user1
                }else{
                    redirect(action:"adminMenu")
                    session.user= user1
                }
                
            }else {
               
                redirect(action:"login")
                session.user= null
            }
        }
        def logout = {
            session.user= null
            redirect(action:"login")
        }
    

}
